package com.balabala.gym_goods.controller.app;

import com.balabala.gym_enum.ResultEnum;
import com.balabala.gym_goods.pojo.dto.EvaluationQueryDto;
import com.balabala.gym_goods.pojo.entity.Evaluation;
import com.balabala.gym_goods.pojo.vo.EvaluationVo;
import com.balabala.gym_goods.service.EvaluationService;
import com.balabala.result.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author fsj
 * @date 2023/5/5 19:15
 */
@RestController
@Slf4j
@CrossOrigin
@Api(tags = "评价管理app接口")
@RequestMapping("/app/evaluation")
public class EvaluationServiceAppController {
    @Autowired
    private EvaluationService evaluationService;


    @GetMapping(value = "/findEvaluationBySpuId")
    @ApiOperation(value = "根据商品id查询评价")
    public Result findEvaluationBySpuId(@RequestParam Long spuId) {

        List<Evaluation> evaluationBySpuId = evaluationService.findEvaluationBySpuId(spuId);

        return Result.ok(evaluationBySpuId);
    }



    /*@PostMapping(value = "/list")
    @ApiOperation(value = "条件查询评价")
    public Result list(@RequestBody EvaluationQueryDto evaluationQueryDto) {
        //1.构建分页条件
        PageHelper.startPage(evaluationQueryDto.getPage(), evaluationQueryDto.getLimit());
        List<EvaluationVo> evaluationVoList = evaluationService.findCoachById(evaluationQueryDto);
        PageInfo<EvaluationVo> pageInfo = new PageInfo<>(evaluationVoList);
        return Result.ok(evaluationVoList, pageInfo.getTotal());
    }*/




}
